<template>
  <div class="more">
    <van-popup v-model="show" :style="{ width: '85%' }">
      <van-cell-group v-if="infoList" @click="infoList = false">
        <van-cell icon="arrow-left" />
        <van-cell
          v-for="(item, index) in typeList"
          :key="index"
          :value="item.name"
          @click="reportArt(artid, item.type, item.name)"
        />
      </van-cell-group>
      <van-cell-group v-else>
        <van-cell title="不感兴趣" icon="failure" @click="dislike" />
        <van-cell
          title="反馈垃圾内容"
          icon="warning-o"
          is-link
          @click="infoList = true"
        />
        <van-cell title="拉黑作者" icon="delete" @click="defriend" />
      </van-cell-group>
    </van-popup>
  </div>
</template>

<script>
import { dislikearticle, reporArticle, blacklist } from '@/api/article.js'
export default {
  props: ['artid', 'autid'],
  data () {
    return {
      show: false,
      infoList: false,
      typeList: [
        { type: 0, name: '其他问题' },
        { type: 1, name: '标题夸张' },
        { type: 2, name: '低俗色情' },
        { type: 3, name: '错别字多' },
        { type: 4, name: '旧闻重复' },
        { type: 5, name: '广告软文' },
        { type: 6, name: '内容不实' },
        { type: 7, name: '涉嫌违法犯罪' },
        { type: 8, name: '侵权' }
      ]
    }
  },
  methods: {
    // 不喜欢
    async dislike () {
      // 在主页删除文章
      this.$emit('delarticle', this.artid)
      await dislikearticle(this.artid)
      this.show = false
    },
    // 举报文章
    async reportArt (artid, type, remark) {
      await reporArticle(artid, type, remark)
      this.show = false
      this.infoList = true
    },
    // 拉黑作者
    async defriend () {
      await blacklist(this.autid)
      this.show = false
    }
  }
}
</script>

<style></style>
